const path = require('path');
const fs = require('fs');

const env = process.env.NODE_ENV || 'local';
const envFile = `.env.${env}`;
const envPath = path.join(__dirname, envFile);

if (fs.existsSync(envPath)) {
  require('dotenv').config({ path: envPath });
  console.log(`已加载环境配置: ${envFile}`);
} else {
  require('dotenv').config();
  console.log('已加载环境配置: .env (默认)');
}

module.exports = {
  gitlab: {
    baseUrl: process.env.GITLAB_BASE_URL || 'https://gitlab.com',
    accessToken: process.env.GITLAB_ACCESS_TOKEN,
    username: process.env.GITLAB_USERNAME
  },
  storage: {
    batchSize: parseInt(process.env.BATCH_SIZE) || 100
  }
};